<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>结算单管理</title>
    <#include "/common/link.ftl">

    <script>
        $(function () {

            $(".btn-input").click(function () {
                Swal.fire({
                    title: '温馨提示',
                    text: "未选定任何预约单,是否需要关联预约单!",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '去关联',
                    cancelButtonText: '不关联!'
                }).then((result) => {
                    console.log(result.value);
                    if(result.value) {
                        //去关联
                        window.location.href = "/appointment/list"
                    }else{
                        //结算单添加
                        window.location.href = "/consumption/input"
                    }
                });
            })






        })



    </script>
</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="consumption"/>
    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>结算单管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 20px 0px 0px 10px">
                    <form class="form-inline" id="searchForm" action="/consumption/list" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                                <div class="form-group">
                                    <label>结算单状态</label>
                                    <select class="form-control cstatus"  name="status" >
                                        <option value="-1">全部</option>
                                        <option value="0">待结算</option>
                                        <option value="1">待审核</option>
                                        <option value="2">归档</option>
                                        <option value="3">坏账</option>
                                    </select>
                                    <script>
                                        $(".cstatus").val('${qo.status}');
                                    </script>
                                </div>
                                <div class="form-group">
                                    <label>门店查询</label>
                                    <select class="form-control cbusines" name="businessId">
                                        <option value="-1">请选择门店</option>
                                        <#list businesses as b>
                                            <option value="${b.id}">${b.name}</option>
                                        </#list>
                                    </select>

                                    <script>
                                        $(".cbusines").val('${qo.businessId}');
                                    </script>
                                </div>
                               <#-- <div class="form-group">
                                    <label>预约类型</label>
                                    <select class="form-control" >
                                        <option value="">请选择预约类型</option>
                                        <option value="1">预约</option>
                                        <option value="0">非预约</option>
                                    </select>
                                </div>-->

                                <div class="form-group">
                                    <label>客户名称</label>
                                    <input type="text" class="form-control"  placeholder="请输入客户名称"  name="customerName"
                                      value="${qo.customerName!}"
                                    >
                                </div>

                                <div class="form-group">
                                    <label>客户手机号</label>
                                    <input type="text" class="form-control" placeholder="请输入客户手机号" name="customerTel"
                                           value="${qo.customerTel!}"
                                    >
                                </div>
                                <div class="form-group">
                                    <label>预约单流水号</label>
                                    <input type="text" class="form-control" placeholder="请输入客户手机号" name="appointmentAno"
                                           value="${qo.appointmentAno!}"
                                    >
                                </div>
                                <br/>
                                <br/>

                        <div class="form-group">
                            <label>结算单流水号</label>
                            <input type="text" class="form-control" placeholder="请输入结算单流水号" name="cno"
                                   value="${qo.cno!}"
                            >
                        </div>

                        <div class="form-group">
                            <label>结算时间查询：</label>
                            <input placeholder="请输入开始时间" type="text"  class="form-control "  name="beginDate"
                               value="${(qo.beginDate?string('yyyy-MM-dd'))!}"
                            /> -
                            <input placeholder="请输入结束时间" type="text"  class="form-control "  name="endDate"
                                   value="${(qo.endDate?string('yyyy-MM-dd'))!}"
                            />
                        </div>

                        <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                            <a href="javascript:;" class="btn btn-success btn-input">
                                <span class="glyphicon glyphicon-plus"></span> 添加
                            </a>
                    </form>

                </div>
                <div class="box-body table-responsive ">
                <table class="table table-hover table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>流水号</th>
                        <th>预约单号</th>
                        <th>客户名称</th>
                        <th>联系方式</th>
                        <th>总消费金额</th>
                        <th>实收金额</th>
                        <th>结算时间</th>
                        <th>结算人</th>
                        <th>消费门店</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    <#list pageInfo.list as c>
                        <tr>
                            <td>${c_index + 1}</td>
                            <td>${c.cno!}</td>
                            <td>${c.appointmentAno!}</td>
                            <td>${c.customerName!}</td>
                            <td>${c.customerTel!}</td>
                            <td>${c.totalAmount!}</td>
                            <td>${c.payAmount!}</td>
                            <td>${(c.payTime?string("yyyy-MM-dd HH:mm"))!}</td>
                            <td>${(c.payee.name)!}</td>
                            <td>${(c.business.name)!}</td>
                            <td>${c.statusDisplay!}</td>
                            <td>
                                <a href="/consumption/input?id=${c.id}" class="btn btn-info btn-xs btn-detail" >
                                    <span class="glyphicon glyphicon-pencil"></span> 详情
                                </a>
                            </td>
                        </tr>
                    </#list>

                    </tbody>
                </table>
                    <!--分页-->
                    <#include "/common/page.ftl">
                </div>

            </div>
        </section>
    </div>
    <#include "/common/footer.ftl">
</div>

</body>
</html>